import React from "react";
import { LocationOutline } from "antd-mobile-icons";
import useScroll from "@/hooks/useScroll";
import classNames from "classnames";
import "./BackTop.scss";

const BackTop = () => {

   const { scroll } = useScroll();

   const handleScrollTop = () => {
      window.scrollTo({
         top: 0,
         left: 0,
         behavior: "smooth",
      });
   };

   return (
      <div className={classNames("back-top", scroll.top >= 900 ? "show" : "")} onClick={handleScrollTop}>
         <LocationOutline />
      </div>
   );
};

export default BackTop;
